package free.mrchen.boot.gate.server.vo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class RVo {

    private int code;

    private String message;

    private Object data;

    public static Builder builder() {
        return new RVo.Builder(new RVo());
    }

    public static Builder success( Object data ) {
        return builder().code(200).data( data );
    }

    public static Builder failureMessage( String message ) {
        return builder().code(500).message(message);
    }

    public static class Builder {

        private final RVo r;

        private Builder(RVo r) {
            this.r = r;
        }

        public Builder code( int code ) {
            r.code = code;
            return this;
        }

        public Builder message( String message ) {
            r.message = message;
            return this;
        }

        public Builder data( Object data ) {
            r.data = data;
            return this;
        }



        public RVo build() {
            return r;
        }


    }


    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public Object getData() {
        return data;
    }
}
